package com.example.test.file;

import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;

import java.io.File;

public class Main {
    public static void main(String[] args) throws Exception {
        test01();
    }

    /**
     * 文件夹监视
     **/
    private static void test01() throws Exception {
        File dir = new File("/home/wangbo");
        FileAlterationObserver observer = new FileAlterationObserver(dir);
        FileListener listener = new FileListener();
        observer.addListener(listener);
        FileAlterationMonitor monitor = new FileAlterationMonitor(1000L, observer);

        monitor.start();
    }
}
